package FM2_15577.back_end;

import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws Exception {
        ServerSocket ss = null;
        try {
            int LISTEN_PORT = 10007;
            ss = new ServerSocket(LISTEN_PORT);
            System.out.println(String.format("Listening at port %d", LISTEN_PORT));
            while (true) {
                Socket s = ss.accept();
                new Thread(new ServerHandler(s)).start();
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        } finally {
            try {
                if (ss != null) {
                    ss.close();
                }
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
            }
        }
    }    
}
